package basic.flow 
{
	import flash.events.EventDispatcher;
	import flash.utils.getTimer;
	/**
	 * ...
	 * @author ...
	 */
	[Event(name = "success", type = "basic.flow.FlowEvent")]
	[Event(name = "fault", type = "basic.flow.FlowEvent")]
	public class Flow extends EventDispatcher
	{
		private var m_id:String = "";
		public function Flow(idx:String = "" ) 
		{
			if(idx==""){
				m_id = "id" + getTimer() + Math.random();
			}else {
				m_id = idx;
			}
		}
		
		/**
		 * 获取ID
		 */
		public function get id():String {
			return m_id;
		}
		
		/**
		 * 设置ID
		 */
		public function set id(value:String):void {
			m_id = value;
		}
		
		/**
		 * 元素替换
		 * @param	obj		需要替换的对象
		 * @param	len		长度
		 * @param	char	替换的长度
		 * @return
		 */
		private static function replenish(obj:Object,len:int=2,char:String="0"):String{
			var src:String=obj+"";
			var xlen:int=len-src.length;
			var i:int=0;
			if(xlen>0){
				for(i=0;i<xlen;i++){
					src=char+src;
				}
			}else{
				for(i=0;i>xlen;i--){
					src=src.substring(1,src.length);
				}
			}
			return src;
		}
		
		/**
		 * 执行当前流程
		 */
		public function exec():void {
			
		}
		
		public override function toString():String {
			return "Flow:"+this.id;
		}
	}

}